using System;
using System.Collections.Generic;
using System.Text;
using emp.Model.SysManage;
using emp.BLL.SysManage;
using System.Web;
using emp.Utility;

namespace emp.ProcessFlow.SysManage
{
    public class RoleUserController
    {
        private const string URL_USER_LIST = "user_list.aspx";
        private const string URL_ROLE_LIST = "role_list.aspx";

        public bool CreateByUser(RoleUserInfo newInfo, string sCurPage, string sMenuID)
        {

            try
            {
                // Creata a new business logic tier
                RoleUser myRoleUser = new RoleUser();

                // Call the insert method
                if (myRoleUser.InsertByUser(newInfo) < 1)
                {
                    return false;
                }

                //Finally forward to the welcome page
                HttpContext.Current.Response.Redirect(URL_USER_LIST + "?page=" + sCurPage + "&MenuID=" + sMenuID, true);

            }
            catch (Exception error)
            {
                string sMethod = "emp.ProcessFlow.RoleUserController.CreateByUser(RoleUserInfo newInfo, string sCurPage)";
                EventsLog.WriteLog(error, sMethod);
                return false;
            }

            return true;
        }


        public bool CreateByRole(RoleUserInfo newInfo, string sCurPage)
        {

            try
            {
                // Creata a new business logic tier
                RoleUser myRoleUser = new RoleUser();

                // Call the insert method
                if (myRoleUser.InsertByRole(newInfo) < 1)
                {
                    return false;
                }

                //Finally forward to the welcome page
                HttpContext.Current.Response.Redirect(URL_ROLE_LIST + "?page=" + sCurPage, true);

            }
            catch (Exception error)
            {
                string sMethod = "emp.ProcessFlow.RoleUserController.InsertByRole(RoleUserInfo newInfo, string sCurPage)";
                EventsLog.WriteLog(error, sMethod);
                return false;
            }

            return true;
        }
    }
}
